<template>
    <div class="top">
        <div class="left">
            <span class="lbtn" @click="backHome">首页</span>
        </div>
        <div class="center">
            <div class="title">智慧旅游可视化大数据平台</div>
        </div>
        <div class="right">
            <span class="rbtn">统计报告</span>
            <span class="time">当前时间:{{ time }}</span>
        </div>
    </div>
</template>
<script setup lang="ts">
import router from '@/route';
import moment from 'moment';
import { ref, onMounted, onBeforeUnmount } from 'vue';

//存储当前时间
let time = ref(moment().format('YYYY年MM月DD日 HH:mm:ss'));
let timer = ref(0);
const backHome = ()=>{
    router.push({name:'home'})
}
onMounted(()=>{
    timer.value = setInterval(()=>{
        time.value = moment().format('YYYY年MM月DD日 HH:mm:ss');
    },1000)
})
onBeforeUnmount(()=>{
    clearInterval(timer.value);
})
</script>
<style scoped lang="less">
.top{
    width: 100%;
    height: 40px;
    display: flex;
    .left{
        flex: 1.5;
        background: url('../../../assets/images/datascreen/dataScreen-header-left-bg.png') no-repeat;
        background-size: cover;
        overflow: hidden;
        .lbtn{
            width: 150px;
            height: 40px;
            float: right;
            background: url(../../../assets/images/datascreen/dataScreen-header-btn-bg-l.png) no-repeat;
            background-size: 100% 100%;
            text-align: center;
            line-height: 40px;
            color: #29fcff;
            font-size: 20px;
            &:hover{
                cursor: pointer;
            }
        }
    }
    .center{
        flex:2;
        .title{
            width: 100%;
            height: 74px;
            background: url(../../../assets/images/datascreen/dataScreen-header-center-bg.png) no-repeat;
            line-height: 74px;
            text-align: center;
            color: #29fcff;
            font-size: 30px;
        }
    }
    .right{
        flex:1.5;
        background: url(../../../assets/images/datascreen/dataScreen-header-right-bg.png) no-repeat;
        background-size: cover;
        overflow: hidden;
        
        .rbtn{
            width: 150px;
            height: 40px;
            float: left;
            background: url(../../../assets/images/datascreen/dataScreen-header-btn-bg-r.png) no-repeat;
            background-size: 100% 100%;
            text-align: center;
            line-height: 40px;
            color: #29fcff;
            font-size: 20px;
            &:hover{
                cursor: pointer;
            }
        }
        .time{
            float: left;
            text-align: center;
            line-height: 40px;
            color: #29fcff;
            font-size: 14px;
            position:relative;
            left: 12%;
        }
    }
}
</style>